//
//  YRJBaseViewController.m
//  YanRenjie
//
//  Created by dllo on 15/11/6.
//  Copyright (c) 2015年 yanrenjie. All rights reserved.
//

#import "YRJBaseViewController.h"
#import "YRJSingleton.h"
#import "YRJNightManager.h"


@interface YRJBaseViewController ()

@end

@implementation YRJBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //修改UInavigationBar的字体颜色(系统API没有这个设置 只能自己建一个Label覆盖 然后修改label的属性)
    
    //将状态栏的颜色改为白色,需要在info.plist中将View controller-based status bar appearance改为NO
    //    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; // navigationController背景图片导致状态栏为白色时看不清
    
    self.view.backgroundColor = [UIColor whiteColor];
    //更改导航栏的默认返回bar,保留箭头,并将颜色改为白色
    UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationItem.backBarButtonItem = bar;
    
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    //将导航栏的标题更改大小和颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    // 夜间模式
    if ([YRJSingleton shareSingleton].isNight) {
        [self setNightDayModel];
    } else {
        [self setLightDayModel];
    }
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLightDayModel) name:@"NightDayNSNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setNightDayModel) name:@"LightDayNSNotification" object:nil];
    
}

- (void)setLightDayModel {
    
    
    [YRJNightManager setBackgroundColorWithView:self.view];
    
}

- (void)setNightDayModel {
    
    [YRJNightManager setBackgroundColorWithView:self.view];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
